/**
 * Created by Peter on 2016/4/27.
 */
define(['jquery'], function ($) {
    return {
        round: function (numberRound, digit) {
            if(!this.isNumeric(numberRound) || numberRound == null) {
                return numberRound == null ? "" : numberRound;
            }
            // return new Number(numberRound).toFixed(digit);

            if (numberRound >= 0) {
                var tempNumber = parseInt((numberRound * Math.pow(10, digit) + 0.5)) / Math.pow(10, digit);
                return tempNumber.toFixed(digit);
            }
            else {
                var numberRound1 = Math.abs(numberRound);
                var tempNumber = parseInt((numberRound1 * Math.pow(10, digit) + 0.5)) / Math.pow(10, digit);
                return "-" + tempNumber.toFixed(digit);
            }
        },
        isNumeric: function (d) {
            var n = Number(d);
            if (!isNaN(n)) {
                return true;
            }
            return false;
        },
        isNaN: function (d) {
            if(d == 'Infinity') {
                return true;
            }
            var n = Number(d);

            return isNaN(n);
        },
        str2Number: function (d) {
            var n = Number(d);
            if (!isNaN(n)) {
                return n;
            }

            return NaN;
        }
    }
});